package com.dbh.company;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.dbh.company.buildbook.bean.ConfigParam;
import com.dbh.company.buildbook.bean.ConfigVO;
import com.dbh.company.buildbook.bean.RespBase;
import com.dbh.company.util.S3Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author dongbanghui
 * @create 2023/11/1
 */
public class ComplianceDelete2 {

    private static final Logger LOGGER = LoggerFactory.getLogger(ComplianceDelete2.class);

    /**
     * 收集s3的key
     * @return
     */
//    public static RespBase getS3KeyList(Long projectNum) {
//        ConfigParam configParam = new ConfigParam();
//        configParam.setProjectNum(projectNum);
//        String url = "http://pre-mr.ke.com/api/config/getConfigById";
//        String body = HttpRequest
//                .post(url)
//                .body(JSONUtil.toJsonStr(configParam))
//                .execute()
//                .body();
//        RespBase respBase = JSON.parseObject(body, RespBase.class);
//        return respBase;
//    }
//
//    public static void main(String[] args) throws IOException, InterruptedException {
//        List<String> strList = new ArrayList<>();
//        strList.add("545831");
//        copyData(strList);
//    }
//
//    private static void copyData(List<String> list) {
//        String bucket = "element-library";
//        for (int i = 0; i < list.size(); i++) {
//            String item = list.get(i);
//            try {
//                RespBase s3KeyList = getS3KeyList(Convert.toLong(item));
//                ConfigVO data = s3KeyList.getData();
//                String covertKey = data.getCovertKey();
//                if (StrUtil.isNotEmpty(covertKey)) {
//                    byte[] bytes = S3Util2.getInputStream(bucket, covertKey);
//                    S3Util.upload(bucket, covertKey, bytes, "mage/jpeg");
//                }
//                List<String> imageKeyList = data.getImageKeyList();
//                for (String imageKey : imageKeyList) {
//                    if (StrUtil.isNotEmpty(imageKey)) {
//                        byte[] bytes = S3Util2.getInputStream(bucket, imageKey);
//                        S3Util.upload(bucket, imageKey, bytes, "mage/jpeg");
//                    }
//                }
//                List<String> panoramaFileKeyList = data.getPanoramaFileKeyList();
//                for (String panoramaFileKey : panoramaFileKeyList) {
//                    if (StrUtil.isNotEmpty(panoramaFileKey)) {
//                        byte[] bytes =  S3Util2.getInputStream("hdic-3d", panoramaFileKey);
//                        S3Util.upload("hdic-3d", panoramaFileKey, bytes, "mage/jpeg");
//                    }
//                }
//                List<String> thumbKeyList = data.getThumbKeyList();
//                for (String thumbKey : thumbKeyList) {
//                    if (StrUtil.isNotEmpty(thumbKey)) {
//                        byte[] bytes = S3Util2.getInputStream(bucket, thumbKey);
//                        S3Util.upload(bucket, thumbKey,bytes, "mage/jpeg");
//                    }
//                }
//                List<String> imageMatrixKeyList = data.getImageMatrixKeyList();
//                for (String imageMatrixKey : imageMatrixKeyList) {
//                    if (StrUtil.isNotEmpty(imageMatrixKey)) {
//                        byte[] bytes = S3Util2.getInputStream(bucket, imageMatrixKey);
//                        S3Util.upload(bucket, imageMatrixKey,bytes, "mage/jpeg");
//                    }
//                }
//                Console.log("项目所有数据复制成功,项目id为:{}", item);
//            } catch (Exception e) {
//            }
//        }
//    }

}
